<form id="auto-data-form" action="org/saveOrUpdate" class="form-horizontal bv-form" method="post" role="form">
	<div style="display: none;">
		<input id="model.id" name="model.id" value="#(model.id)" placeholder="机构主键" type="hidden" />
		<input id="model.sort" name="model.sort" value="#(model.sort)" placeholder="排序号" type="hidden" />
		<input id="model.parentId" name="model.parentId" value="#(model.parentId)" placeholder="上级机构" type="hidden" />
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label">上级机构</label>
		<div class="col-sm-10">
			<input value="#(parent.name??)" class="form-control input-md" readonly="readonly"/>
		</div>
	</div>
	<div class="form-group">
		<label for="model.code" class="col-sm-2 control-label">机构编码</label>
		<div class="col-sm-10">
			<input id="model.code" name="model.code" value="#(model.code)" placeholder="机构编码" #if(model.id)readonly="readonly" #end class="form-control input-md" required maxlength="64"/>
		</div>
	</div>
	
	<div class="form-group">
		<label for="model.name" class="col-sm-2 control-label">机构名称</label>
		<div class="col-sm-10">
			<input id="model.name" name="model.name" value="#(model.name)" placeholder="机构名称" class="form-control input-md" required maxlength="64" />
		</div>
	</div>
	
	<div class="form-group">
		<label for="model.type" class="col-sm-2 control-label">机构类型</label>
		<div class="col-sm-10">
			#@dict_select("model.type",model.type,"ORG_TYPE",false,"机构类型","required")
		</div>
	</div>
	
	<div class="form-group">
		<label for="model.state" class="col-sm-2 control-label">机构状态</label>
		<div class="col-sm-10">
			#@dict_select("model.state",model.state,"DATA_STATE",false,"机构状态","required")
		</div>
	</div>
	
	<div class="form-group">
		<label for="model.remark" class="col-sm-2 control-label">机构描述</label>
		<div class="col-sm-10">
			<textarea id="model.remark" name="model.remark" placeholder="机构描述" class="form-control input-md auto" maxlength="1024">#(model.remark)</textarea>
		</div>
	</div>
	<div id="ztree_form_tools" class="form-group text-center" style="display: none;">
		<button type="button" class="btn btn-success auto-btn auto-submit-ajax" data-interceptor="_interceptor" data-callback="_callback"><i class="fa fa-check-square"></i>&nbsp;&nbsp;保存</a></button>
	</div>	
</form>
<script type="text/javascript">
function _interceptor(){
	var node=_getCurrentNode();
	if(node==null||(node.level==0&&jid("model.type").val()!="01")){
		showMsg("顶级机构的类型必须为单位！","error");
		return false;
	}
	return true;
}
function _callback(data){
	if(data.success) {
		jid("model.id").val(data.data);
		_updateZtreeNode(data.data,jid("model.name").val());
	}
}
$(document).ready(function() {
	if(ztree_mgr_pv){
		$("#ztree_form_tools").show();
	}
});
</script>